//
//  ZooDataView.m
//  兼职页面
//
//  Created by kuiyuan liang on 2021/5/23.
//

#import "ZooDataView.h"
#import "CommonUtil.h"

@interface ZooDataView()



@end

@implementation ZooDataView

-(instancetype)initWithFrame:(CGRect)frame{
    if (self = [super initWithFrame:frame]) {
        
        [self addSubview:self.heightView];
        [self addSubview:self.dataView];
        [self addSubview:self.titleLabel];
        self.dataView.centerX = self.heightView.centerX;
    }
    return self;
}


-(void)refreshData:(NSString *)data{
    
    self.titleLabel.text = data;
    if ([data isEqualToString:@"鼠"]) {
        self.heightView.backgroundColor = RGB(159.0, 92.0, 190.0);
        self.dataView.backgroundColor = RGB(139.0, 75.0, 170.0);
        //self.backgroundColor = [UIColor redColor];
    }else if ([data isEqualToString:@"牛"]){
        self.heightView.backgroundColor = RGB(160.0, 203.0, 61.0);
        self.dataView.backgroundColor = RGB(128.0, 174.0, 42.0);
    }else if ([data isEqualToString:@"虎"]){
        self.heightView.backgroundColor = RGB(0.0, 172.0, 222.0);
        self.dataView.backgroundColor = RGB(0.0, 149.0, 195.0);
    }else if ([data isEqualToString:@"兔"]){
        self.heightView.backgroundColor = RGB(255.0, 177.0, 64.0);
        self.dataView.backgroundColor = RGB(234.0, 150.0, 48.0);
    }else if ([data isEqualToString:@"龙"]){
        self.heightView.backgroundColor = RGB(242.0, 97.0, 100.0);
        self.dataView.backgroundColor = RGB(235.0, 33.0, 44.0);
    }else if ([data isEqualToString:@"蛇"]){
        self.heightView.backgroundColor = RGB(159.0, 92.0, 190.0);
        self.dataView.backgroundColor = RGB(139.0, 75.0, 170.0);
    }else if ([data isEqualToString:@"1尾"]){
        self.heightView.backgroundColor = RGB(160.0, 160.0, 160.0);
        self.dataView.backgroundColor = RGB(132.0, 132.0, 132.0);
    }
}



-(UILabel *)dataView{
    if (!_dataView) {
        CGFloat w = _heightView.width + AD(10);
        _dataView = [[UILabel alloc] initWithFrame:CGRectMake(0, AD(20), w, AD(20))];
        _dataView.text = @"(1人)";
        _dataView.textColor = [UIColor whiteColor];
        _dataView.font = [UIFont systemFontOfSize:AD(13)];
        _dataView.textAlignment = NSTextAlignmentCenter;
        
    }
    return _dataView;
}

-(UIView *)heightView{
    if (!_heightView) {
        CGFloat w = self.width - AD(20);
        _heightView = [[UIView alloc] initWithFrame:CGRectMake(AD(10), AD(10), w, self.height-AD(10)-AD(30))];
        
    }
    return _heightView;
}

-(UILabel *)titleLabel{
    if (!_titleLabel) {
        _titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, _heightView.bottom, self.width, AD(30))];
        _titleLabel.textColor = [UIColor lightGrayColor];
        _titleLabel.font = [UIFont systemFontOfSize:AD(13)];
        _titleLabel.textAlignment = NSTextAlignmentCenter;
    }
    return _titleLabel;
}




@end
